package org.lgiavedoni.android.franq.core.envent.listener;

import java.util.Observable;
import java.util.Observer;

import org.lgiavedoni.android.franq.core.envent.Event;
import org.lgiavedoni.android.franq.service.log.Logger;

public abstract class EventListener implements Observer {

	@Override
	public void update(Observable o, Object event) {
		if (event instanceof Event) {

			try {
				getClassEvent().cast(event);
				exec((Event) event);
			} catch (ClassCastException ex) {
				// Do nothing
				// Is not the right listener
			} catch (Exception ex) {
				Logger.inst.error(ex);
			}
		}
	}

	public abstract void exec(Event event);

	public abstract Class<? extends Event> getClassEvent();

}
